@page "/users"
@attribute [TabItemOption(Text = "用户管理")]

<PageTitle>用户管理</PageTitle>

@if (_hasPermission)
{
    <!-- 只读权限提示 -->
    @if (_isReadOnly)
    {
        <div class="alert alert-warning mb-3" role="alert">
            <i class="fa-solid fa-eye me-2"></i>
            <strong>只读权限提示：</strong>您当前拥有只读权限，可以查看用户信息但无法修改。
        </div>
    }

    <Table TItem="Application.Core.Entity.User" AutoGenerateColumns="true" class="table-demo" @bind-Items="EditItems"
           IsPagination="true" PageItemsSource="PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"  AllowResizing="true"
           ShowSkeleton="true" ShowToolbar="true" ShowSearch="true" ShowExtendButtons="@(!_isReadOnly)"
           ShowExportButton="@(!_isReadOnly)"
           OnQueryAsync="OnQueryAsync" OnSaveAsync="OnSaveAsync" OnDeleteAsync="OnDeleteAsync"
           IsAutoRefresh="true" AutoRefreshInterval="2000"
           ShowAddButton="@_canAdd" ShowEditButton="@_canEdit" ShowDeleteButton="@_canDelete"
           ShowLineNo="true" ShowExtendButtonColumn="@(!_isReadOnly)" ShowDefaultButtons="@(!_isReadOnly)">
    </Table>
}
else
{
    @* <div class="container-fluid d-flex align-items-center justify-content-center" style="height: 80vh;">
        <div class="text-center">
            <div class="mb-4">
                <i class="fa-solid fa-ban fa-5x text-danger"></i>
            </div>
            <h1 class="display-4 text-danger mb-3">访问被拒绝</h1>
            <p class="lead mb-4">您没有权限访问用户管理页面。</p>
            <button class="btn btn-primary" @onclick="GoToHome">
                <i class="fa-solid fa-home me-2"></i>返回首页
            </button>
        </div>
    </div> *@
}


